package testLayer;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import controlLayer.ClassRoomCtr;

public class ClassRoomControllerTest {
	
	private ClassRoomCtr classRoomCtr;
	
	@Before
	public void setUp() throws Exception {
		
		this.classRoomCtr = new ClassRoomCtr();
		this.insert();
		
	}
	
	@After
	public void tearDown() throws Exception {
		
		this.remove();
		this.classRoomCtr = null;
		
	}
	
	public void insert() throws Exception {
		
		this.classRoomCtr.createClassRoom("L07b", "blank");
				
	}
	
	@Test
	public void find() throws Exception {
		
		assertTrue(this.classRoomCtr.findClassRoom("L07b") != null);
	
	}
	
	@Test
	public void findById() throws Exception {
		
		if (this.classRoomCtr.findById(this.classRoomCtr.findClassRoom("L07b").getId()) != null);
	
	}
	
	@Test
	public void getAll() throws Exception {
		
		assertTrue(!this.classRoomCtr.getAll().isEmpty() && 1 <= this.classRoomCtr.getAll().size());

	}
	
	@Test
	public void update() throws Exception {
		
		assertTrue(this.classRoomCtr.updateClassRoom(this.classRoomCtr.findClassRoom("L07b").getId(),
								  			  "L07b", "Common Purpose Lecture Room") > 0);

	}
	
	public void remove() throws Exception {
		
		this.classRoomCtr.removeClassRoom("L07b");
		
	} 

}
